package com.sskj.mine.presenter;

import com.lzy.okgo.model.Response;
import com.sskj.common.base.HttpData;
import com.sskj.common.util.ToastUtil;
import com.sskj.lib.http.JsonCallBack;
import com.sskj.mine.http.HttpConfig;
import com.sskj.mine.ui.activity.MineVerificationHighActivity;

import java.io.File;

public class MineVerificationHighPresenter extends BasePresenter<MineVerificationHighActivity> {
    /**
     * 上传图片
     *
     * @param file 文件
     * @return
     */
    public void uploadImg(File file) {
        httpService.uploadImg(file)
                .execute(new JsonCallBack<HttpData<String>>(this) {
                    @Override
                    public void onSuccess(Response<HttpData<String>> response) {
                        HttpData<String> httpData = response.body();
                        if (httpData.getStatus() == HttpConfig.OK) {
                            mView.updatePath(httpData.getData());
                        }
                    }
                });
    }

    /**
     * 实名认证
     *
     * @param username       用户名
     * @param idCardNo       身份证号
     * @param idCardFrontImg 前身份证
     * @param idCardBackImg  后身份证
     * @param selfieImg      手持
     * @return
     */
    public void verify(String username, String idCardNo, String idCardFrontImg, String idCardBackImg, String selfieImg) {
        httpService.verify(username, idCardNo, idCardFrontImg, idCardBackImg, selfieImg)
                .execute(new JsonCallBack<HttpData>(this) {
                    @Override
                    public void onSuccess(Response<HttpData> response) {
                        HttpData httpData = response.body();
                        ToastUtil.showShort(httpData.getMsg());
                        if (httpData.getStatus() == HttpConfig.OK) {
                            mView.onSubmitVerifyResponseSuccess();
                        }
                    }
                });
    }
}
